﻿Public Class NewEmployee

    Private Sub BtnClose_Click(sender As System.Object, e As System.EventArgs)
        Me.Close()
    End Sub

    Private Sub BtnAddNew_Click(sender As System.Object, e As System.EventArgs) Handles BtnAddNew.Click
        Dim values As New Dictionary(Of String, String)
        Dim databaseProvider As DatabaseProvider = databaseProvider.Instance()

        If TxtPosition.Text.Length <= 1 Or TxtName.Text.Length <= 1 Or TxtSurname.Text.Length <= 1 Or TxtTown.Text.Length <= 1 Or TxtPostcode.Text.Length <= 1 Then
            MsgBox("Position, Name, Surname, Town and Postcode are required")
        Else
            values.Add("position", TxtPosition.Text)
            values.Add("name", TxtName.Text)
            values.Add("surname", TxtSurname.Text)
            values.Add("town", TxtTown.Text)
            values.Add("postcode", TxtPostcode.Text)
            values.Add("line1", TxtAddress1.Text)
            values.Add("line2", TxtAddress2.Text)
            values.Add("mobile", TxtMobile.Text)
            values.Add("home_tel", TxtHome.Text)
            values.Add("start_date", TxtStartDate.Text)
            values.Add("end_date", TxtEndDate.Text)
            values.Add("first_aid", CBFirstAid.Checked)

            'zaladuj dane do Employee
            databaseProvider.InsertEmployee(values)
            'odswiez Grida
            Employee.EmployeeDataGrid.DataSource = databaseProvider.GetAllEmployees()
        End If
    End Sub

    Private Sub NewEmployee_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
       
    End Sub

    Private Sub BtnClose_Click_1(sender As System.Object, e As System.EventArgs) Handles BtnClose.Click
        Me.Close()
    End Sub
End Class